package com.huawei.aiservice.impl.strategy;

import com.huawei.aiservice.entity.pojo.FileEntity;
import com.huawei.aiservice.entity.pojo.Rule;
import com.huawei.aiservice.service.DefectService;
import com.huawei.aiservice.service.FileRuleService;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.web.multipart.MultipartFile;

import java.util.Map;

public class RuleContext {
    private RuleStrategy strategy;
    private final Map<MultipartFile, FileEntity> map;
    private final ThreadPoolTaskExecutor executor;
    private final Rule rule;
    private final DefectService defectService;

    private final String fragment;

    private final FileRuleService fileRuleService;

    public RuleContext(RuleStrategy strategy, Map<MultipartFile, FileEntity> map, ThreadPoolTaskExecutor executor,
                       Rule rule, DefectService defectService, String fragment, FileRuleService fileRuleService) {
        this.strategy = strategy;
        this.map = map;
        this.executor = executor;
        this.rule = rule;
        this.defectService = defectService;
        this.fragment = fragment;
        this.fileRuleService = fileRuleService;
    }

    public void executeStrategy() {
        strategy.execute(map, executor, rule, defectService, fragment, fileRuleService);
    }
}
